CM3D2 Converter.misc_VIEW3D_MT_edit_mesh_specials
1# 「3Dビュー」エリア → メッシュ編集モード → 「W」キー 2import bpy 3import bmesh 4from . import common 5from . import compat 6 7 8# メニュー等に項目追加 9def menu_func(self, context): 10 icon_id = common.kiss_icon() 11 self.layout.separator() 12 self.layout.operator('mesh.selected_mesh_vertex_group_blur', icon_value=icon_id) 13 self.layout.separator() 14 self.layout.operator('mesh.selected_face_sort_front', text="選択面の描画順を最前面に", icon_value=icon_id).is_back = False 15 self.layout.operator('mesh.selected_face_sort_front', text="選択面の描画順を最背面に", icon_value=icon_id).is_back = True 16 17 18@compat.BlRegister() 19class CNV_OT_selected_mesh_sort_front(bpy.types.Operator): 20 bl_idname = 'mesh.selected_face_sort_front' 21 bl_label = "選択面の描画順を最前面に" 22 bl_description = "選択中の面の描画順を最も前面/背面に並び替えます" 23 bl_options = {'REGISTER', 'UNDO'} 24 25 is_back = bpy.props.BoolProperty(name="最背面") 26 27 @classmethod 28 def poll(cls, context): 29 ob = context.active_object 30 return ob and ob.type == 'MESH' and ob.mode == 'EDIT' 31 32 def execute(self, context): 33 ob = context.active_object 34 me = ob.data 35 bm = bmesh.from_edit_mesh(me) 36 37 bm.faces.ensure_lookup_table() 38 39 selected_face_indexs = [] 40 other_face_indexs = [] 41 for face in bm.faces: 42 if face.select: 43 selected_face_indexs.append(face.index) 44 else: 45 other_face_indexs.append(face.index) 46 47 output_face_indexs = [] 48 if not self.is_back: 49 output_face_indexs = other_face_indexs + selected_face_indexs 50 else: 51 output_face_indexs = selected_face_indexs + other_face_indexs 52 53 for for_index, sorted_index in enumerate(output_face_indexs): 54 bm.faces[sorted_index].index = for_index 55 56 bm.faces.sort() 57 bmesh.update_edit_mesh(me) 58 return {'FINISHED'}
@compat.BlRegister()
class
CNV_OT_selected_mesh_sort_front19@compat.BlRegister() 20class CNV_OT_selected_mesh_sort_front(bpy.types.Operator): 21 bl_idname = 'mesh.selected_face_sort_front' 22 bl_label = "選択面の描画順を最前面に" 23 bl_description = "選択中の面の描画順を最も前面/背面に並び替えます" 24 bl_options = {'REGISTER', 'UNDO'} 25 26 is_back = bpy.props.BoolProperty(name="最背面") 27 28 @classmethod 29 def poll(cls, context): 30 ob = context.active_object 31 return ob and ob.type == 'MESH' and ob.mode == 'EDIT' 32 33 def execute(self, context): 34 ob = context.active_object 35 me = ob.data 36 bm = bmesh.from_edit_mesh(me) 37 38 bm.faces.ensure_lookup_table() 39 40 selected_face_indexs = [] 41 other_face_indexs = [] 42 for face in bm.faces: 43 if face.select: 44 selected_face_indexs.append(face.index) 45 else: 46 other_face_indexs.append(face.index) 47 48 output_face_indexs = [] 49 if not self.is_back: 50 output_face_indexs = other_face_indexs + selected_face_indexs 51 else: 52 output_face_indexs = selected_face_indexs + other_face_indexs 53 54 for for_index, sorted_index in enumerate(output_face_indexs): 55 bm.faces[sorted_index].index = for_index 56 57 bm.faces.sort() 58 bmesh.update_edit_mesh(me) 59 return {'FINISHED'}
is_back: <_PropertyDeferred, <built-in function BoolProperty>, {'name': '最背面', 'attr': 'is_back'}> =
<_PropertyDeferred, <built-in function BoolProperty>, {'name': '最背面', 'attr': 'is_back'}>
def
execute(self, context):
33 def execute(self, context): 34 ob = context.active_object 35 me = ob.data 36 bm = bmesh.from_edit_mesh(me) 37 38 bm.faces.ensure_lookup_table() 39 40 selected_face_indexs = [] 41 other_face_indexs = [] 42 for face in bm.faces: 43 if face.select: 44 selected_face_indexs.append(face.index) 45 else: 46 other_face_indexs.append(face.index) 47 48 output_face_indexs = [] 49 if not self.is_back: 50 output_face_indexs = other_face_indexs + selected_face_indexs 51 else: 52 output_face_indexs = selected_face_indexs + other_face_indexs 53 54 for for_index, sorted_index in enumerate(output_face_indexs): 55 bm.faces[sorted_index].index = for_index 56 57 bm.faces.sort() 58 bmesh.update_edit_mesh(me) 59 return {'FINISHED'}
Inherited Members
- bpy_types.Operator
- as_keywords
- poll_message_set
- builtins.bpy_struct
- keys
- values
- items
- get
- pop
- as_pointer
- keyframe_insert
- keyframe_delete
- driver_add
- driver_remove
- is_property_set
- property_unset
- is_property_readonly
- is_property_overridable_library
- property_overridable_library_set
- path_resolve
- path_from_id
- type_recast
- bl_rna_get_subclass_py
- bl_rna_get_subclass
- id_properties_ensure
- id_properties_clear
- id_properties_ui
- id_data